package com.rupertjones.globalcron.web;

import com.rupertjones.globalcron.web.model.DisplayableAuditLog;
import com.rupertjones.globalcron.web.service.AuditLogService;
import net.sourceforge.stripes.action.Before;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.controller.LifecycleStage;
import net.sourceforge.stripes.integration.spring.SpringBean;

import java.util.List;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class InfoAuditLogAction extends AbstractAction {

    @SpringBean
    private AuditLogService auditLogService;

    @Before(stages = LifecycleStage.BindingAndValidation)
    public void loadAndBind() {
    }

    @DefaultHandler
    public Resolution view() {
        return new ForwardResolution(INFO_AUDIT_LOG_JSP);
    }

    public List<DisplayableAuditLog> getAuditLogs() {
        return auditLogService.findAll();
    }
}
